June 14, 2019
v3 SendSMS
Description:
Send a text (SMS) or multi-media message (MMS)
URI:
https://api.multitel.net/v3/sendsms
Parameters:
Required: from - your SMS enabled phone number to - destination number text - text message we will be sending Optional: media - base64 encoded image (jpg/png) notifyurl - if provided, we will post back any status changes to this URL. (example: https://customer-crm.xyz/notify-handler ) reference - your own reference ; will be useful since you might have several messages with the same from/to parameters ; passing the reference parameter will help you identify which message the status update is for
Methods:
POST
Sample Output:
{ "status": { "code":"200", "msg":"" }, "response": { "status":"Success", "message":"Message queued", "causecode":0, "uniqueid":"eba01f56-1fbe-4aac-9ff7-4a6b9e00001", "cost":0.015, "chars":0, "parts":1, "permsg":0.015, "pid":"ZQF88E7031eba01f56-1fbe-4aac-9ff7-4a6b9e00001" } }
Sample code:
! note: change the YOURUSERNAME and YOURPASSWORD keywords with your own username/password <?php if( isset($_POST['submit']) ) { $url = "https://api.multitel.net/v3/sendsms"; $media_f = $_FILES['media']; $tmpName = $media_f['tmp_name']; $fp = fopen($tmpName, 'r'); $data_file = addslashes(fread($fp, filesize($tmpName))); $media = base64_encode($data_file); fclose($fp); rename($media_f['tmp_name'], $media_f['name']); $params = array( 'from' => $_POST['from'], 'to' => $_POST['to'], 'text' => $_POST['text'], 'media' => $media, 'notifyurl' => '', 'reference' => 'test123' ); $curlopt = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_MAXREDIRS => 10, // stop after 10 redirects CURLOPT_ENCODING => "", // handle compressed CURLOPT_USERAGENT => "YOURUSERNAME", // name of client CURLOPT_AUTOREFERER => true, // set referrer on redirect CURLOPT_CONNECTTIMEOUT => 120, // time-out on connect CURLOPT_TIMEOUT => 120, // time-out on response CURLOPT_POST => true, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => 'YOURUSERNAME:YOURPASSWORD', CURLOPT_POSTFIELDS => $params ); $ch = curl_init($url); curl_setopt_array($ch, $curlopt); $content = curl_exec($ch); curl_close($ch); $result = json_decode($content); echo "result: <br>"; echo $content; echo "<br>end result"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Send SMS</title> </head> <body> <form name="form1" method="post" action="" enctype="multipart/form-data"> From : <input type="text" name="from" value="" /> (11 digits 1+N10) <br /> To : <input type="text" name="to" value="" /> (11 digits 1+N10) <br /> Text message : <textarea name="text">test%0a123</textarea> <br /> Image: <input type="file" name="media"> <input type="submit" name="submit" value="submit" /> </form> </body> </html>